<template>
  <div class="container">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item
          ><span style="color: #417ced">出库管理</span></el-breadcrumb-item
        >
        <el-breadcrumb-item>内部出库</el-breadcrumb-item>
      </el-breadcrumb>
      <!-- 展示收款金额 -->
      <div class="money" style="margin-top: 15px" v-if="!is_null(tableData)">
        <div class="headerNav">
          <span>金额状态</span>
        </div>
        <div class="contentTotal">
          <p>
            <span>已收金额：￥{{ tableData.receivedMoney }}</span>
          </p>
          <p>
            <span>待收金额：￥{{ tableData.awaitIncomeMoney }}</span>
          </p>
          <p>
            <span>总金额：￥{{ tableData.total }}</span>
          </p>
        </div>
      </div>
      <!-- 面包屑导航 -->
      <div class="state">
        <p class="header" v-if="!is_null(tableData)">
          订单状态：{{ orderType[tableData.orderStatus-1] }}
        </p>
        <ul>
          <li>
            <p>制单人: {{ tableData.createdName }}</p>
            <p>部门名称: {{ tableData.consigneeDepaName }}</p>
            <p>出库类型: {{ tableData.typeName }}</p>
          </li>
          <li>
            <p>下单时间: {{ $moment(tableData.createdTime) }}</p>
            <p>订单编号: {{ tableData.orderId }}</p>
          </li>
        </ul>
      </div>
      <div class="address">
        <p class="header">收货人信息</p>
        <ul>
          <li v-if="tableData">
            <p>收货人姓名: {{ tableData.consignee }}</p>
            <p>联系电话: {{ tableData.receivingPhone }}</p>
            <p>收货地址: {{ tableData.address + tableData.addressDetails }}</p>
          </li>
          <li v-if="tableData">
            <p>备注: {{ tableData.comment }}</p>
          </li>
        </ul>
      </div>
      <div class="orderBox">
        <p class="header">订单商品</p>
        <el-table
          :data="tableData.interiorOrderCommodities"
          style="width: 100%"
        >
          <el-table-column prop="commodityName" label="商品名称"></el-table-column>
          <el-table-column
            prop="number"
            label="商品数量"
            width="180"
          ></el-table-column>
          <el-table-column prop="price" label="商品单价"></el-table-column>
          <el-table-column prop="brandName" label="商品品牌"></el-table-column>
          <el-table-column prop="classifyName" label="商品分类"></el-table-column>
          <el-table-column
            prop="specificationName"
            label="商品规格"
          ></el-table-column>
          <el-table-column label="商品小计">
			  <template slot-scope="scope">
				  {{scope.row.price * scope.row.number}}
			  </template>
		  </el-table-column>
        </el-table>
        <el-table
          :data="tableData.interiorOrderComplimentaries"
          style="width: 100%"
        >
          <el-table-column
            prop="complimentaryName"
            label="赠品名称"
          ></el-table-column>
          <el-table-column
            prop="number"
            label="赠品数量"
            width="180"
          ></el-table-column>
          <el-table-column prop="price" label="赠品单价"></el-table-column>
          <el-table-column prop="brandName" label="赠品品牌"></el-table-column>
          <el-table-column prop="classifyName" label="赠品分类"></el-table-column>
          <el-table-column
            prop="specificationName"
            label="赠品规格"
          ></el-table-column>
          <el-table-column label="赠品小计">
			  <template slot-scope="scope">
				  {{scope.row.price * scope.row.number}}
			  </template>
		  </el-table-column>
        </el-table>
      </div>
      <div class="total">
        <p v-if="tableData">总计：共 {{ count() }} 件</p>
        <p v-if="tableData">
          运费：{{ tableData.charge ? tableData.charge : 0 }}
        </p>
        <p v-if="tableData">总价：{{ tableData.money }}</p>
      </div>
    </div>
    <div class="oldOrder">
			<div class="title">
				关联异常单号
			</div>
			<el-table  :data="tableData.returnGoodsDetailResponses" style="width:100%;">
				<el-table-column type="expand">
					<template slot-scope="scope">
						商品
						<el-table border :data="scope.row.orderReturnCommodityList" style="width:100%;">
							<el-table-column label="图片">
								<template slot-scope="scope">
									<el-image style="width: 100px; height: 100px" :src="img(scope.row.image)" fit="cover"></el-image>
								</template>
							</el-table-column>
							<el-table-column prop="brandName" label="品牌"></el-table-column>
							<el-table-column prop="name" label="商品名称"></el-table-column>
							<el-table-column prop="number" label="商品数量"></el-table-column>
							<el-table-column prop="price" label="单价"></el-table-column>
							<el-table-column label="规格" prop="specificationName">
							</el-table-column>
							<el-table-column prop="total" label="商品小计"></el-table-column>
						</el-table>
						赠品
						<el-table border :data="scope.row.orderReturnComplimentaryList" style="width:100%;">
							<el-table-column label="图片">
								<template slot-scope="scope">
									<el-image style="width: 100px; height: 100px" :src="img(scope.row.image)" fit="cover"></el-image>
								</template>
							</el-table-column>
							<el-table-column prop="brandName" label="品牌"></el-table-column>
							<el-table-column prop="complimentaryName" label="商品名称"></el-table-column>
							<el-table-column prop="number" label="商品数量"></el-table-column>
							<el-table-column prop="price" label="单价"></el-table-column>
							<el-table-column label="规格" prop="specificationName">
							</el-table-column>
							<el-table-column prop="total" label="商品小计"></el-table-column>
						</el-table>
					</template>
				</el-table-column>
				<el-table-column prop="returnOrderId" label="订单编号"></el-table-column>
				<el-table-column prop="customerName" label="客户"></el-table-column>
				<el-table-column prop="applyName" label="客服"></el-table-column>
				<el-table-column prop="orderType" label="订单状态"></el-table-column>
				<el-table-column prop="returnMoney" label="金额"></el-table-column>
				<el-table-column label="包裹单号">
					<template slot-scope="scope">
						{{scope.row.parcelNumber}}
					</template>
				</el-table-column>
				<el-table-column label="收货信息">
					<template slot-scope="scope">
						<span>{{ scope.row.addressName }}</span>
						<span> {{ scope.row.addressPhone }} </span>
						<span> {{ scope.row.address }}</span>
					</template>
				</el-table-column>
				<el-table-column prop="applyTime" label="下单时间"></el-table-column>
			</el-table>
		</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      queryType: this.$route.query,
      errorOrder: [],
      tableData: {},
      orderType: [
        "待提交",
        "审核中",
        "驳回",
        "待发货",
        "已发货",
        "待签收",
        "已签收",
      ],
    };
  },
  created() {
    this.getDetail();
  },
  methods: {
    is_null(tableData) {
      if (tableData) {
        return false;
      } else {
        return true;
      }
    },
    getDetail() {
      this.axios
        .get(
          "order/v1/internal/interiorOrder/interiorOrderDetails?orderId=" +
            this.$route.query.orderId
        )
        .then((res) => {
          if (res.code == 0) {
            this.tableData = res.data;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    img(img) {
      return this.ImgHttps + img;
    },
    count() {
      let count = 0;
      if (this.tableData.interiorOrderCommodities) {
        this.tableData.interiorOrderCommodities.forEach((res) => {
          count += res.number;
        });
      }
      if (this.tableData.interiorOrderComplimentaries) {
        this.tableData.interiorOrderComplimentaries.forEach((res) => {
          count += res.number;
        });
      }

      return count;
    },
  },
};
</script>

<style scoped lang="scss">
.header {
  font-size: 15px;
  color: #2d7edf;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}
.state {
  background: #fff;
  padding: 10px;
  ul {
    margin: 10px 0;
    li {
      margin-left: 50px;
      line-height: 40px;
      font-size: 15px;
      p {
        display: inline-block;
        margin-right: 50px;
      }
      span {
        display: inline-block;
        margin-left: 20px;
        color: #2d7edf;
        font-weight: bold;
      }
    }
  }
}

/deep/.el-table thead .cell {
  text-align: center !important;
}
/deep/.el-table td,
.el-table th {
  text-align: center;
}
.money {
  background: #fff;
  padding: 10px;
  margin-bottom: 15px;
  .contentTotal {
    p {
      display: inline-block;
      font-size: 15px;
      margin-right: 20px;
      color: #dd6161;
      margin: 15px 0 15px 10px;
    }
  }
}
/deep/.el-button {
  padding: 8px 10px;
}
/deep/.el-table thead {
  color: #2d7edf;
  .cell {
    text-align: left;
  }
}
.address {
  background: #fff;
  padding: 10px;
  margin: 15px 0;
  ul {
    margin: 10px 0;
    li {
      margin-left: 50px;
      line-height: 40px;
      font-size: 15px;
      p {
        display: inline-block;
        margin-right: 50px;
      }
    }
  }
}
.orderBox {
  background: #fff;
  padding: 10px;
}
.total {
  margin: 15px 0;
  background: #fff;
  padding: 20px 10px;
  text-align: right;
  p {
    display: inline-block;
    font-size: 15px;
    color: #2d7edf;
    margin-left: 30px;
    font-weight: bold;
  }
}
.fix {
  background: #fff;
  padding: 10px;
  margin-bottom: 20px;
}
.headerNav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  > span {
    color: #2d7edf;
  }
  .right {
    display: flex;
    justify-content: flex-end;
    align-items: center;

    p {
      margin-left: 10px;
      font-size: 15px;
      color: #333;
    }
  }
}
/deep/.el-dialog__body {
  padding: 10px 20px;
}
.qrcode {
  display: flex;
  justify-content: flex-start;
  span {
    display: inline-block;
    width: 100px;
  }
}
#contentQr {
  height: 150px;
  width: 150px;
  margin: 20px auto 10px;
}
</style>
